package com.ruoyi.kong.service.impl;

import com.ruoyi.kong.entity.KongCertificate;
import com.ruoyi.kong.entity.KongEntity;
import com.ruoyi.kong.fegin.KongClientService;
import com.ruoyi.kong.service.IKongCertificateService;
import com.ruoyi.kong.utils.KongActiveProfileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class KongCertificateServiceImpl implements IKongCertificateService {

    @Autowired
    private KongActiveProfileUtil kongActiveProfileUtil;

    @Override
    public KongEntity<KongCertificate> certificates() {
        return KongClientService.getInstance(kongActiveProfileUtil.getKongServerUrl()).certificates();
    }

    public KongCertificate certificateById(String id){
        return KongClientService.getInstance(kongActiveProfileUtil.getKongServerUrl()).certificateById(id);
    }
    public KongCertificate addCertificate(KongCertificate certificate){
        return  KongClientService.getInstance(kongActiveProfileUtil.getKongServerUrl()).addCertificate(certificate);
    }
    public void deleteCertificate(String id){
        KongClientService.getInstance(kongActiveProfileUtil.getKongServerUrl()).deleteCertificate(id);
    }
    public KongCertificate updateCertificate(String id,KongCertificate certificate){
        return KongClientService.getInstance(kongActiveProfileUtil.getKongServerUrl()).updateCertificate(id,certificate);
    }
}
